package com.gameShare.controller.game

import com.gameShare.controller.base.BaseController
import com.gameShare.entity.dto.game.GameCardDto
import com.gameShare.entity.po.game.GameInfo
import com.gameShare.entity.vo.PageVo
import com.gameShare.entity.vo.ResponseVo
import com.gameShare.service.game.GameInfoService
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("/gameInfo")
class GameInfoController(private val gameInfoService: GameInfoService) : BaseController() {

    /**
     *获取游戏卡片信息
     *月份信息是用1,2,3的格式存储的不符合的为非法参数，
     *当order参数为null时候默认为post_type
     * orderType默认为ASC升序
     * @param year 年份
     * @param monthList 月份
     * @param lang 语言
     * @param type 类型
     * @param platform 平台
     * @param pageNo 当前页数
     * @param pageSize 页大小
     * @param order 排序字段
     * @param orderType 排序类型升序降序
     * @return gameCard的分页对象
     */
    @RequestMapping("/getGameCardPage")
    fun getGameInfo(year : String?, monthList : String?, lang : Int?, type : Int?, platform: Int?, pageNo : Int?, pageSize : Int?, order : Int?, orderType : Int?): ResponseVo<PageVo<GameCardDto?>> {


        val resultVo = gameInfoService.getGameCardPage(
            year = year,
            monthList = monthList,
            gameType = type,
            gameLang = lang,
            gamePlatform = platform,
            pageNo = pageNo,
            pageSize = pageSize,
            order = order,
            orderType = orderType
        )
        return getSuccessResponseVO(resultVo)
    }

    @RequestMapping("/getGameDetail")
    fun getGameDetail(){
        gameInfoService
    }

    /**
     * 获取随机一个游戏
     *
     * @return 游戏信息
     */
    @RequestMapping("/getRandomGame")
    fun getRandomGame(): ResponseVo<GameInfo> {
        return getSuccessResponseVO(gameInfoService.getRandomInfo())
    }
}